home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / SystemCode / BackCompatibility.tcl < prev    next >
Encoding:
Text File  |  2000-12-06  |  11.7 KB  |  440 lines

  1. # You should avoid calling any of these procs:
  2. # They are slower, and may be removed at some point in the future.
  3. # Some of these are currently called from Alpha's main menus.  This
  4. # will be changed in the future, so that this entire file can vanish.
  5.  
  6. # just wrappers around other procs
  7.  
  8. if {[info exists warningForObsoleteProcedures] && ($warningForObsoleteProcedures == 1)} {
  9.     # To help ensure Alpha(tk) doesn't need anything from here.
  10.     if {[askyesno "Some code requires [array names unknown_pending]; please\
  11.       try to remove that dependence on deprecated procedures.  Throw an error?"] == "yes"} {
  12.     error "Code required [array names unknown_pending]"
  13.     }
  14. }
  15.  
  16. proc realMenuName {name} {
  17.     global subMenuInfo
  18.     return [lindex $subMenuInfo($name) 1]
  19. }
  20. proc rebuildSimpleFilesetMenus {} {
  21.     global gfileSets
  22.     eval [menu::makeFlagMenu choose list currFileSet]
  23.     Menu -n hideFileset -m -p filesetMenu::hideOrShow [lsort [array names gfileSets]]
  24.     filesetUtilsMarksTicks
  25. }
  26.  
  27. proc killWindowStatus {} { closeAWindow }
  28. proc chooseWindowStatus {} { chooseAWindow }
  29.  
  30. proc sPromptChoices {msg def choices} {
  31.     uplevel 1 prompt::fromChoices [list $msg $def -list $choices]
  32. }
  33.  
  34. proc sPrompt {msg def} {
  35.     global useStatusBar
  36.     if {!$useStatusBar} {return [prompt $msg $def]}
  37.     if {[catch {statusPrompt "$msg ($def): "} ans]} {
  38.     error "cancel"
  39.     }
  40.     if {![string length $ans]} {return $def}
  41.     return $ans
  42. }
  43.  
  44. # This is superceded by more general completion/prompt routines which
  45. # do the same thing when told to use '-command winNames'.
  46. proc winComp {curr c} {
  47.     if {$c != "\t"} {return $c}
  48.     
  49.     set matches {}
  50.     foreach w [winNames] {
  51.     if {[string match "$curr*" $w]} {
  52.         lappend matches $w
  53.     }
  54.     }
  55.     if {![llength $matches]} {
  56.     error "No match"
  57.     } else {
  58.     return [string range [largestPrefix $matches] [string length $curr] end]
  59.     }
  60.     return ""
  61. }
  62.  
  63. namespace eval file {}
  64. namespace eval help {}
  65.  
  66. proc file::searchAndHyperise {args} { uplevel 1 win::searchAndHyperise $args }
  67. proc file::multiSearchAndHyperise {args} { uplevel 1 win::multiSearchAndHyperise $args }
  68. proc file::jumpToCode {args} { uplevel 1 win::jumpToCode $args }
  69.  
  70. proc file::hyperHelpFileOpen { name } {
  71.     help::openGeneral $name
  72. }
  73. proc file::hyperOpen {name} {
  74.     help::openHyper $name
  75. }
  76.  
  77. proc file::hyperHelpOpen { name } {
  78.     help::openGeneral $name
  79. }
  80. proc file::hyperExampleOpen {{f ""}} {
  81.     help::openExample $f
  82. }
  83.  
  84. proc openFolder {args} {
  85.     uplevel 1 file::showInFinder $args
  86. }
  87. proc pushMark {} {pushPosition}
  88. proc popMark {} {popPosition}
  89. proc pushPosition {args} {uplevel placeBookmark $args}
  90. proc popPosition {args} {uplevel returnToBookmark $args}
  91. proc absolutePath {filename} {file::absolutePath $filename}
  92. proc openFileQuietly {filename} {
  93.     edit -c -w $filename
  94. }
  95. proc searchInFile {filename searchString {indices 0}} {
  96.     file::searchFor $filename $searchString $indices
  97. }
  98.  
  99. proc readFile {fileName} {file::readAll $fileName}
  100. proc writeFile {filename {text {}} {overwrite 0}} {
  101.     file::writeAll $filename $text $overwrite
  102. }
  103. proc gotoFileLine {fname line {mesg {}}} {
  104.     file::gotoLine $fname $line $mesg
  105. }
  106.  
  107. proc buildSubMenu {args} {
  108.     eval menu::buildHierarchy $args
  109. }
  110.  
  111. proc listSubfolders {folder {depth 3}} {
  112.     file::hierarchy $folder $depth
  113. }
  114.  
  115. proc getIncludeFiles {} { optClickTB_List }
  116. proc editIncludeFile {item} { optClickTB_Pick $item}
  117. proc tryElseDump {name script} {
  118.     try::level \#0 $script -reporting log -while $name
  119. }
  120. proc text::genericIndent {} { ::indentLine }
  121.  
  122. proc revertTheseFiles {flist} {eval file::revertThese $flist}
  123.  
  124. proc file::commentTextBlock {args} { eval comment::TextBlock $args }
  125. proc commentLine  {args} { uplevel 1 comment::Line $args }
  126. proc uncommentLine  {args} { uplevel 1 comment::undoLine $args }
  127. proc commentBox  {args} { uplevel 1 comment::Box $args }
  128. proc uncommentBox  {args} { uplevel 1 comment::undoBox $args }
  129. proc commentCharacters {args} { uplevel 1 comment::Characters $args }
  130. proc commentGetRegion  {args} { uplevel 1 comment::GetRegion $args }
  131. proc commentSameStart  {args} { uplevel 1 comment::SameStart $args }
  132. proc commentTextBlock  {args} { uplevel 1 comment::TextBlock $args }
  133. proc commentGetFillLines {args} { uplevel 1 comment::GetFillLines $args }
  134. proc commentParagraph  {args} { uplevel 1 comment::Paragraph $args }
  135. proc uncommentParagraph {args} { uplevel 1 comment::undoParagraph $args }
  136. proc fillParagraph {args} {uplevel 1 paragraph::fill $args}
  137. proc fillOneParagraph {args} {uplevel 1 paragraph::fillOne $args}
  138. proc paraStart {args} {uplevel 1 paragraph::start $args}
  139. proc paraFinish {args} {uplevel 1 paragraph::finish $args}
  140. proc sentenceParagraph {args} {uplevel 1 paragraph::sentence $args}
  141. proc selectParagraph {args} {uplevel 1 paragraph::select $args}
  142. proc addArrDef {args} { uplevel 1 prefs::addArrayElement $args }
  143. proc removeArrDef {args} { uplevel 1 prefs::removeArrayElement $args }
  144. proc addDef {args} {uplevel 1 prefs::add $args}
  145. proc removeDef {args} {uplevel 1 prefs::remove $args}
  146. proc readDefs {args} {uplevel 1 prefs::_read $args}
  147. proc writeDefs {args} {uplevel 1 prefs::_write $args}
  148. proc addArr {args} { uplevel 1 prefs::addArray $args }
  149. proc removeArr {args} { uplevel 1 prefs::removeArray $args }
  150. proc saveModifiedVars {args} { uplevel 1 prefs::saveModified $args }
  151. proc alpha::readUserDefs {} {uplevel 1 prefs::readAll}
  152. proc alpha::readUserPrefs {} {uplevel 1 prefs::tclRead}
  153. proc addUserLine {args} { uplevel 1 prefs::tclAddLine $args}
  154. namespace eval mode {}
  155. proc mode::addUserLine {args} {uplevel 1 prefs::tclAddModeLine $args}
  156. proc getSavedSettings {} {prefs::listAllSaved}
  157.  
  158. proc upBrowse {} { browse::Up }
  159. proc downBrowse {} { browse::Down }
  160. proc gotoMatch {} { browse::Goto }
  161.  
  162. proc stripNameCount str { win::StripCount $str }
  163.  
  164. ########################################
  165. #                           #
  166. #    A few random lisp'ish functions.  #
  167. #                       #
  168. ########################################
  169.  
  170. proc car {l} {lindex $l 0}
  171. proc cadr {l} {lindex $l 1}
  172. proc caddr {l} {lindex $l 2}
  173. proc cadddr {l} {lindex $l 3}
  174. proc caddddr {l} {lindex $l 4}
  175. proc cdr {l} {lrange $l 1 end}
  176. proc cddr {l} {lrange $l 2 end}
  177.  
  178. proc mapcar args {return [eval map $args]}
  179.  
  180. proc map {func l} {
  181.     set out {}
  182.     foreach el $l {
  183.     lappend out [eval $func [list $el]]
  184.     }
  185.     return $out
  186. }
  187.  
  188. proc cons {e l} {concat [list $e] $l}
  189.  
  190. # ◊◊◊◊ Legacy TclAE Definitions ◊◊◊◊ #
  191.  
  192. ## 
  193.  # -------------------------------------------------------------------------
  194.  # 
  195.  # "aebuild::*" --
  196.  # 
  197.  #  Wrapper routines for tclAE::build::*. Don't call these in new code.
  198.  # 
  199.  # -------------------------------------------------------------------------
  200.  ##
  201.  
  202. namespace eval aebuild {}
  203.  
  204. proc aebuild::result {args} {
  205.     return [eval tclAE::build::resultData $args]
  206. }
  207.  
  208. proc aebuild::objectProperty {process property object} {
  209.     return [tclAE::build::objectProperty $process $property $object]
  210. }
  211.  
  212. proc aebuild::coercion {type value} {
  213.     return [tclAE::build::coercion $type $value]
  214. }
  215.  
  216. proc aebuild::list {l args} {
  217.     return [eval tclAE::build::List [list $l] $args]
  218. }
  219.  
  220. proc aebuild::hexd {value} {
  221.     return [tclAE::build::hexd $value]
  222. }
  223.  
  224. proc aebuild::bool {val} {
  225.     return [tclAE::build::bool $val]
  226. }
  227.  
  228. proc aebuild::TEXT {str} {
  229.     return [tclAE::build::TEXT $str]
  230. }
  231.  
  232. proc aebuild::alis {path} {
  233.     return [tclAE::build::alis $path]
  234. }
  235.  
  236. proc aebuild::fss {value} {
  237.     return [tclAE::build::fss $value]
  238. }
  239.  
  240. proc aebuild::name {name} {
  241.     return [tclAE::build::name $name]
  242. }
  243.  
  244. proc aebuild::filename {name} {
  245.     return [tclAE::build::filename $name]
  246. }
  247.  
  248. proc aebuild::winByName {name} {
  249.     return [tclAE::build::winByName $name]
  250. }
  251.  
  252. proc aebuild::winByPos {absPos} {
  253.     return [tclAE::build::winByPos $absPos]
  254. }
  255.  
  256. proc aebuild::lineRange {absPos1 absPos2} {
  257.     return [tclAE::build::lineRange $absPos1 $absPos2]
  258. }
  259.  
  260. proc aebuild::absPos {posName} {
  261.     return [tclAE::build::absPos $posName]
  262. }
  263.  
  264. proc aebuild::startupDisk {} {
  265.     return [tclAE::build::startupDisk]
  266. }
  267.  
  268. proc aebuild::userName {} {
  269.     return [tclAE::build::userName]
  270. }
  271.  
  272.  
  273. namespace eval aeparse {}
  274.  
  275. proc aeparse::event {chars args} {
  276.     return [eval tclAE::parse::event [list $chars] $args]
  277. }
  278.  
  279. proc aeparse::keywordValue {keyword record {typed 0}} {
  280.     if {$typed} {
  281.         return [tclAE::getKeyDesc $record $keyword]
  282.     } else {
  283.         return [tclAE::getKeyData $record $keyword]
  284.     }
  285. }
  286.  
  287.  
  288. namespace eval aecoerce {}
  289.  
  290. proc aecoerce::identity {value} {
  291.     return $value
  292. }
  293.  
  294. proc aecoerce::hexd:bool {value} {
  295.     binary scan $value c bool
  296.     
  297.     if {![info exists bool]
  298.     ||    ($bool != 0 && $bool != 1)} {
  299.         error::throwOSErr -1700
  300.     }
  301.     
  302.     return $bool
  303. }
  304.  
  305. proc aecoerce::hexd:TEXT {value} {
  306.     binary scan $value a* TEXT
  307.     return $TEXT
  308. }
  309.  
  310. proc aecoerce::hexd {value} {
  311.     error "I have no idea what this is supposed to do"
  312. }
  313.  
  314. proc aecoerce::null:TEXT {value} {
  315.     return [tclAE::coerce::null>hexd $value]
  316. }
  317.  
  318. proc aecoerce::hexd:alis {value} {
  319.     set resultDesc [tclAE::createDesc alis]
  320.     tclAE::coerce::TEXT>alis TEXT $value alis $resultDesc
  321.     set result [tclAE::print $resultDesc]
  322.     tclAE::disposeDesc $resultDesc
  323.     
  324.     return $result
  325. }
  326.  
  327. proc aecoerce::TEXT:alis {value} {
  328.     return [aecoerce::hexd:alis [binary format a* $value]]
  329. }
  330.  
  331. proc aecoerce::register {args} {
  332.     return [eval tclAE::installCoercionHandler $args]
  333. }
  334.  
  335. proc aecoerce::apply {AEDesc toType} {
  336.     set newDesc [tclAE::coerceDesc $AEDesc $toType]
  337.         set result [tclAE::getData $newDesc]
  338.         tclAE::disposeDesc $newDesc
  339.     
  340.     return $result
  341. }
  342.     
  343. proc aecoerce::deregister {hook {procname ""} args} {
  344.     error "There is no way to make \[aecoerce::deregister\] compatible with modern TclAE. \
  345.       The code must be changed to use \[tclAE::removeCoercionHandler\]"
  346. }
  347.  
  348. # I don't believe these are used anywhere, but put them here 
  349. # to avoid the 7.4b17 fiasco
  350.  
  351. namespace eval tclAE {}
  352. namespace eval tclAE::coerce {}
  353.  
  354. proc tclAE::coerce::null>TEXT {value} {
  355.     return ""
  356. }
  357.  
  358. ## 
  359.  # bool ::= bool(«00|01»)
  360.  ##
  361. proc tclAE::coerce::_hexd>bool {value} {
  362.     set value [tclAE::coerce::_long>hexd $value]
  363.     set bool [expr {"0x$value"}]
  364.     if {($bool != 0) && ($bool != 1)} {
  365.         set msg "Can't coerce «$value» from 'hexd' to 'bool'"
  366.         error $msg "" [list AECoerce -1700 $msg]
  367.     } 
  368.     return $bool
  369. }
  370.  
  371. proc tclAE::coerce::_****>hexd {value} {
  372.     set newval $value
  373.     if {[expr {[string length $newval] % 2}]} {
  374.         # left pad with zero to make even number of digits
  375.         set newval "0${newval}"
  376.     } 
  377.     if {![is::Hexadecimal $newval]} {
  378.         set msg "Non-hex-digit in «${value}»" 
  379.         error $msg "" [list AECoerce 6 $msg]
  380.     } else {
  381.         return ${newval}
  382.     }
  383. }
  384.  
  385. proc tclAE::coerce::_hexd>TEXT {value} {
  386.     # make sure input is really hexd
  387.     set value [tclAE::coerce::_****>hexd $value]
  388.  
  389.     set TEXT ""
  390.     set length [string length $value]
  391.     set i 0
  392.     while {$i < $length} {
  393.         append TEXT [uplevel 0 "set temp \\x[string range $value $i [incr i]]"]
  394.         incr i
  395.     }
  396.     return $TEXT
  397. }
  398.  
  399. proc tclAE::coerce::_long>hexd {value} {
  400.     set newval [format "%08X" $value]
  401.     return [tclAE::coerce::_****>hexd $newval]
  402. }
  403.  
  404. proc tclAE::coerce::_shor>hexd {value} {
  405.     set newval [format "%04X" $value]
  406.     return [tclAE::coerce::_****>hexd $newval]
  407. }
  408.  
  409. if {[info tclversion] < 8.0} {
  410.     proc tclAE::coerce::_TEXT>hexd {value} {
  411.             set length [string length $value]
  412.             set hexd ""
  413.             for {set i 0} {$i < $length} {incr i} {
  414.                     if {[set char [string index $value $i]] == "\x00"} {
  415.                             # scan doesn't work on \x00, so we handle it specially.
  416.                             append hexd "00"
  417.                     } else {
  418.                             scan $char "%c" char
  419.                             append hexd [format "%02X" $char]                
  420.                     } 
  421.             }    
  422.             
  423.             return $hexd
  424.     }    
  425. } else {
  426.     proc tclAE::coerce::_TEXT>hexd {value} {
  427.         binary scan $value H* hexd
  428.         return $hexd
  429.     }
  430. }
  431.  
  432.  
  433. # mtime doesn't understand hex notation,
  434. # so we force to decimal first
  435. proc tclAE::coerce::_hexd>ldt {hexd} {
  436.     return [join [mtime [tclAE::coerce::hexd>long $hexd] short]]
  437. }
  438.  
  439.